import request from '@/utils/request'
import qs from 'qs'


// 获取打印机列表
export function printerList(pageNumber, pageSize) {
  return request({
    url: '/print/printer/list_rewrite',
    method: 'get',
    params: {
      storeId:sessionStorage.getItem('storeId'),
      pageNumber,
      pageSize,
    }
  })
}

// 添加打印机
export function printerAdd(printer) {
  return request({
    url: '/print/printer/save',
    method: 'post',
    data: qs.stringify(
      printer
    )
  })
}

// 修改打印机
export function printerUpdate(printer) {
  console.log(printer);
  return request({
    url: '/print/printer/update',
    method: 'post',
    data: qs.stringify(
      printer
    )
  })
}

// 删除打印机
export function printerLogicalDel(ids) {
  return request({
    url: '/print/printer/logical_del',
    method: 'post',
    data: qs.stringify({
      ids,
    }, {indices: false})
  })
}

export function setDefaultPrinter(printerId) {
  return request({
    url: '/print/printer/set_default',
    method: 'post',
    params: {
      printerId,
      storeId:sessionStorage.getItem('storeId'),
    }
  })
}

export function printerSelectItem() {
  return request({
    url: '/print/printer/select_item_rewrite',
    method: 'get',
    params: {
      storeId:sessionStorage.getItem('storeId'),
    }
  })
}
